package logic;

public class CashDesk {
	private CardDataBase cardBase;
	private long lastNumber;
	
	public CashDesk( CardDataBase cardDb){
		cardBase = cardDb;
		lastNumber = 0;
	}
		
	public boolean sellCard( MetroCard metroCard){
		lastNumber += 1;
		metroCard.setCardId(lastNumber);
		cardBase.addCard(metroCard);
		return true;
	}
	
	public boolean rechargeCard( MetroCard metroCard, double money ){
            if ( cardBase.findCard(metroCard) ){
                return metroCard.addMoney(money);
            }
            return false;
	}
        
        public long getLastNumber(){
            return lastNumber;
        }
}
